<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Title</title>
</head>
<body>
<script>
    try{
        let d
        console.log(d.xxx)
    } catch (err) {
        console.log(err)
        console.log(err.message)
        console.log(err.stack)
    }

    // 抛出错误
    function something() {
        if (Date.now()%2===1) {
            console.log('当前时间为奇数，可以执行任务')
        } else {
            throw new Error('当前时间为偶数，无法执行任务')
        }
    }
    // 捕获处理异常
    try {
        something()
    } catch (e) {
        console.log(e)
        console.log(e.message)
    }


</script>
</body>
</html>
